/*  cpu.h
 *  Part of xfce4-cpugraph-plugin
 *
 *  Copyright (c) Alexander Nordfelth <alex.nordfelth@telia.com>
 *  Copyright (c) gatopeich <gatoguan-os@yahoo.com>
 *  Copyright (c) 2007-2008 Angelo Arrifano <miknix@gmail.com>
 *  Copyright (c) 2007-2008 Lidiriel <lidiriel@coriolys.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
#ifndef __XFCE_CPU_H__
#define __XFCE_CPU_H__

#if HAVE_CONFIG_H
#include <config.h>
#endif

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*#include <libxfce4util/libxfce4util.h>
  #include <libxfcegui4/libxfcegui4.h>*/
#include "xfce-panel-plugin.h"
#include "xfce-fake.h"
//#in clude <libxfce4panel/xfce-hvbox.h>

#include "cpu_os.h"


#define BORDER  8

#define MAX_WIDTH 64

typedef struct
{
	GtkWidget *m_Notebook;

	/* Update */
	GtkWidget *m_UpdateOption;
	GtkWidget *m_UpdateMenu;
	GtkWidget *m_UpdateMenuItem;

	GtkWidget *m_Width;
	GtkWidget *m_Height;
	GtkWidget *m_GraphFrame;
	GtkWidget *m_TimeScale;
	GtkWidget *m_AssociateCommand;

	GtkWidget *m_FG1;
	GtkWidget *m_FG2;
	GtkWidget *m_FG3;
	GtkWidget *m_BG;
	GtkWidget *m_FC;
	GtkWidget *m_ColorDA;
	GtkWidget *m_ColorDA2;
	GtkWidget *m_ColorDA3;
	GtkWidget *m_ColorDA4;
	GtkWidget *m_ColorDA5;

	GtkWidget *m_FrameApperance;
	GtkWidget *m_FrameColor;
	GtkWidget *m_FrameMode;

	GtkWidget *m_ModeOption;
	GtkWidget *m_ModeMenu;
	GtkWidget *m_ModeMenuItem;

	GtkWidget *m_OptionMenu;
	GtkWidget *m_Menu;
	GtkWidget *m_MenuItem;
}SOptions;

typedef struct
{
	XfcePanelPlugin *plugin;

	GtkWidget *m_FrameWidget;
	GtkWidget *m_DrawArea;
	GtkWidget *m_OptionsDialog;
	GtkWidget *m_Box;
	GtkWidget **m_pBar;
	SOptions m_Options;

	int m_UpdateInterval; // Number of ms between updates.
	int m_TimeScale; // Wether to use non-linear time scale.
	int m_Width; // The width of the plugin.
	int m_Mode; // Eventual mode of the plugin.
	int m_ColorMode;
	int m_Frame;
	gchar * m_AssociateCommand;
	guint nrCores; // Number of cores (not including total cpu)

	GdkColor m_ForeGround1; // Inactive color.
	GdkColor m_ForeGround2; // Active color.
	GdkColor m_ForeGround3;
	GdkColor m_BackGround; // Background color.

	GtkTooltips *m_Tooltip; // Eventual tooltip.

	guint m_TimeoutID; // Timeout ID for the tooltip;
	long m_CPUUsage;
	float *m_History;
	int m_Values;

	int m_Orientation;


}CPUGraph;

CPUGraph *CreateControl (XfcePanelPlugin *plugin);
void Kill (XfcePanelPlugin *plugin, CPUGraph *base);
void ReadSettings (XfcePanelPlugin *plugin, CPUGraph *base);
void WriteSettings (XfcePanelPlugin *plugin, CPUGraph *base);
gboolean SetSize (XfcePanelPlugin *plugin, int size, CPUGraph *base);
void UserSetSize (CPUGraph *base);
gboolean UpdateCPU (CPUGraph *base);
void UpdateTooltip (CPUGraph *base);
void DrawGraph (CPUGraph *base);
void DrawAreaExposeEvent (GtkWidget *da, GdkEventExpose *event, gpointer data);
void CreateOptions (XfcePanelPlugin *plugin, CPUGraph *base);
void SetOrientation (XfcePanelPlugin *plugin, GtkOrientation orientation, CPUGraph *base);
void SetHistorySize (CPUGraph *base, int size);
void SetRealGeometry (CPUGraph *base);


void ChangeColor1 (GtkButton *button, CPUGraph *base);
void ChangeColor2 (GtkButton *button, CPUGraph *base);
void ChangeColor3 (GtkButton *button, CPUGraph *base);
void ChangeColor4 (GtkButton *button, CPUGraph *base);
void ChangeColor5 (GtkButton *button, CPUGraph *base);
void ChangeColor (int color, CPUGraph *base);
void SpinChange (GtkSpinButton *sb, int *value);
void SetSensitive (CPUGraph *base, GtkWidget *fgA, GtkWidget *fgB, gboolean flag1, gboolean flag2);
void UpdateChange (GtkOptionMenu *om, CPUGraph *base);
void ModeChange (GtkOptionMenu *om, CPUGraph *base);
void ApplyChanges (CPUGraph *base);
void FrameChange (GtkToggleButton *button, CPUGraph *base);
void TimeScaleChange (GtkToggleButton *button, CPUGraph *base);
void AssociateCommandChange(GtkEntry *entry, CPUGraph *base);
void ColorModeChange (GtkOptionMenu *om, CPUGraph *base);
gboolean LaunchCommand (GtkWidget *w, GdkEventButton *event, CPUGraph *base);

#endif
